package com.cysd.ewmxns.sdw_ui.activity

import android.os.Bundle
import android.util.Log
import com.cszy.ewmxns.base.BaseVMActivity

import com.cysd.ewmxns.sdw_viewmodel.TXMScanViewModel
import qrrspeeelild.rqrc0ode.andro0ild.databinding.ActivityTxmScanResultBinding

class Sdw_TxmScanResultActivity : BaseVMActivity<TXMScanViewModel, ActivityTxmScanResultBinding>() {
    override fun initView(savedInstanceState: Bundle?) {

    }

    override fun initData() {
        var scanResult= intent.getStringExtra("scanResult")
        Log.e("qin","scanResult:${scanResult}")
        mViewModel.queryShop(scanResult.toString())
    }

    override fun initObserve() {
        mViewModel.queryQrResult.observe(this){
            // 价格（假设价格可能是数字或字符串，如果是数字可能需要额外处理）
            mBinding.tvPrice.text = "￥"+(it?.price ?: "暂无信息")

            // 名称
            mBinding.tvName.text = it?.name ?: "暂无信息"

            // 其他字段
            mBinding.tvUnspsc.text = it?.unspsc ?: "暂无信息"
            mBinding.tvBrand.text = it?.brand ?: "暂无信息"
            mBinding.tvType.text = it?.type ?: "暂无信息"
            mBinding.tvOrigincountry.text = it?.origincountry ?: "暂无信息"
            mBinding.tvOriginplace.text = it?.originplace ?: "暂无信息"
            mBinding.tvGrossweight.text = it?.grossweight ?: "暂无信息"
            mBinding.tvHealthpermitnum.text = it?.healthpermitnum ?: "暂无信息"
            mBinding.tvLicensenum.text = it?.licensenum ?: "暂无信息"
            mBinding.tvNetweight.text = it?.netweight ?: "暂无信息"
        }

        mViewModel.errorMessage.observe(this){
            Log.e("qin","errorMessage:${it}")
        }
    }
    override fun initListener() {
        mBinding.ivBack.setOnClickListener {
            finish()
        }
    }
}